require(['./config'],()=>{
    require(['swiper','template','header','footer'],(Swiper,template)=>{
        class Index {
            constructor () {
                this.getHomeList()
                this.getBannerList().then(()=>{
                  this.banner()
                })
                // this.getWyList()
                this.getTabList()
                this.getTab2List()
                this.getTab3List()
                this.getTab4List()
                this.getInformationList()
            }
            banner () {
                //swiper是一个满足AMD规范的，所以在上面需要接受Swiper
                var mySwiper = new Swiper ('#banner', {
                    loop: true, // 循环模式选项
                    autoplay:true,
                    // 如果需要分页器
                    pagination: {
                      el: '#banner .swiper-pagination',
                    },
                    // 如果需要前进后退按钮
                    navigation: {
                      nextEl: '#banner .swiper-button-next',
                      prevEl: '#banner .swiper-button-prev',
                    }
                  })      
            }
            getBannerList(){
              return new Promise((resolve,reject)=>{
                $.get('http://xiongmaoyouxuan.com/api/detail',{
                  id:38969124,
                  normal:1,
                  sa:''
                },resp=>{
                  console.log(resp)
                  if(resp.code==200){
                    let {descContentList} = resp.data.detail
                    // console.log(descContentList)
                    let list = descContentList.slice(10,15)
                    // console.log(list)
                    const html = template('bannerTemplate',{list})
                    $('#bannerList').html(html)
                  }
                  resolve()
                })
              })
              
            }
            getHomeList () {
              $.get('http://rap2.taobao.org:38080/app/mock/264805/api/home/shop',resp => {
                if(resp.code==="200"){
                  const {list} = resp.body
                  // console.log(list)
                  const html = template('fourTemplate',{ list })
                  $('#fourList').html(html)
                }
              })
            }
            /* getWyList () {
              //https://www.muji.com.cn/cn/net/contents/corporate/atom.html?_=1598262533101
              //https://apiv2.pinduoduo.com/api/gindex/subject/limited/goods?subject_id=39275&page=1&size=50
              $.get('http://xiongmaoyouxuan.com/api/tabs',{
                sa:''
              },resp=>{
                if(resp.code==200){
                  let {list} = resp.data
                  list=list.slice(0,8)
                 /*  const html = template('fourTemplate',{
                    
                  }) */
                 /*  $('#fourList').html(template('fourTemplate',{ list }))
                }
              })  */
            // }
            getTabList () {
              $.get('http://xiongmaoyouxuan.com/api/tab/1/feeds',{
                start:20,
                sort:0
              },resp=>{
                if(resp.code==200){
                  // console.log(resp)
                  let {list} = resp.data
                  list=list.slice(4,7)
                  $('#more2_imgList').html(template('more2Template',{ list }))
                }
              })
            }
            getTab2List () {
              $.get('http://xiongmaoyouxuan.com/api/tab/1/feeds',{
                start:20,
                sort:0
              },resp=>{
                if(resp.code==200){
                  // console.log(resp)
                  let {list} = resp.data
                  list=list.slice(7,10)
                  $('#more3_imgList').html(template('more3Template',{ list }))
                }
              })
            }
            getTab3List () {
              $.get('http://xiongmaoyouxuan.com/api/tab/1/feeds',{
                start:20,
                sort:0
              },resp=>{
                if(resp.code==200){
                  // console.log(resp)
                  let {list} = resp.data
                  list=list.slice(10,13)
                  $('#more4_imgList').html(template('more4Template',{ list }))
                }
              })
            }
            getTab4List () {
              $.get('http://xiongmaoyouxuan.com/api/tab/1/feeds',{
                start:20,
                sort:0
              },resp=>{
                if(resp.code==200){
                  // console.log(resp)
                  let {list} = resp.data
                  list=list.slice(13,16)
                  $('#more5_imgList').html(template('more5Template',{ list }))
                }
              })
            }
            getInformationList () {
              $.get('http://xiongmaoyouxuan.com/api/tab/1/feeds',{
                start:20,
                sort:0
              },resp=>{
                if(resp.code==200){
                  // console.log(resp)
                  let {list} = resp.data
                  list=list.slice(3,7)
                  $('#more_informationList').html(template('more_informationTemplate',{ list }))
                }
              })
            }

        }
        new Index()
    })
})